<template>
  <view>
      <!-- index.wxml -->
      <view class="view_page">
          <!-- title -->
          <block v-if="activeTab == 0">
              <index-navigate
                  style="position: absolute; left: 0; top: 0; right: 0"
                  :district="areaName"
                  :bgColor="indexTitleBackground"
                  @onSelectCity="onSelectCity"
                  @onSearch="onSearch"
              />
          </block>
          <block v-else-if="activeTab == 1">
              <navbar page-name="关于我们" :showNav="false" />
          </block>
          <block v-else></block>

          <!-- content -->
          <view class="page_content flex_fill page_item">
              <scroll-view v-if="activeTab == 0" style="height: 100%" :scroll-y="true" @scroll="onIndexScroll">
                  <image
                      class="index_title_bg"
                      src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/index/index_title_bg.png"
                      style="height: 509rpx; display: block; box-sizing: border-box; left: 0rpx; top: 0rpx"
                  ></image>
                  <view v-if="false">
                      <van-button type="default" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</van-button>
                  </view>

                  <view :style="'height: ' + (navTop + navContentHeight + 29) + 'px;'"></view>

                  <swiper
                      v-if="indexTopBanners"
                      class="banner_swiper"
                      :circular="true"
                      :autoplay="true"
                      :duration="200"
                      :indicator-dots="true"
                      indicator-color="rgba(0, 0, 0, 0.3)"
                      indicator-active-color="#FF6700"
                  >
                      <swiper-item v-for="(item, index) in indexTopBanners" :key="index">
                          <image
                              style="width: 746rpx; display: block; box-sizing: border-box"
                              :src="item.picUrl"
                              class="banner_image"
                              mode="scaleToFill"
                              @tap="onClickBanner"
                              :data-item="item"
                              :data-index="index"
                          />
                      </swiper-item>
                  </swiper>

                  <view style="height: 70rpx"></view>

                  <view class="index_menu_container flex_row">
                      <view class="index_menu flex_column_c" @tap="onMenuClick" :data-index="tabIndex" v-for="(menu, tabIndex) in indexMenus" :key="tabIndex">
                          <van-image width="116rpx" height="116rpx" :src="menu.icon"></van-image>

                          <view class="index_menu_text">{{ menu.title }}</view>
                      </view>
                  </view>

                  <view style="height: 44rpx"></view>

                  <view style="display: flex; align-items: center; justify-content: center">
                      <van-image
                          style="height: 300rpx; display: block; box-sizing: border-box; width: 673rpx"
                          width="674rpx"
                          height="300rpx"
                          src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/shengji/jinhualiaoxiuyang.png"
                          @tap.native="onLiaoxiuTap"
                      />
                  </view>

                  <view style="height: 20rpx"></view>

                  <view class="action_container" style="width: 750rpx; height: 161rpx; display: inline-flex; box-sizing: border-box">
                      <view class="action_item" @tap="onClickBanner" :data-item="banner" v-for="(banner, index) in indexMiddleBanners" :key="index">
                          <van-image width="100%" height="100%" :src="banner.picUrl"></van-image>
                      </view>
                  </view>

                  <view style="height: 30rpx"></view>

                  <view v-if="latestShops && latestShops.length > 0">
                      <view class="title_container">
                          <image class="title_container_text_icon" src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/icon/icon_new.png"></image>
                          <view class="title_container_text" style="width: 507rpx; display: block; box-sizing: content-box">近期上新</view>
                          <view class="title_container_text_right">更多 ></view>
                      </view>
                      <scroll-view :scroll-x="true" class="horizontal_scroller">
                          <view
                              class="scroller_item"
                              @tap="toLatestDetail"
                              :data-item="shopLatesetItem"
                              v-for="(shopLatesetItem, shopLatestIndex) in latestShops"
                              :key="shopLatestIndex"
                          >
                              <view class="p_r">
                                  <van-image :src="shopLatesetItem.mainPicUrlW" width="256rpx" height="200rpx"></van-image>
                                  <view class="shop_tag_container">
                                      <van-tag type="primary" v-for="(label, index) in util.splitLabel(shopLatesetItem.especialLabel)" :key="index">{{ label }}</van-tag>
                                  </view>
                              </view>

                              <view class="shop_title_single">{{ shopLatesetItem.shopName }}</view>

                              <view class="flex_row_b shop_desc">
                                  <text style="font-size: 22rpx; color: #ff6700; font-weight: bold">￥</text>
                                  <text style="font-size: 36rpx; color: #ff6700; font-weight: bold">{{ shopLatesetItem.startingPriceYuan }}</text>
                                  <text style="font-size: 22rpx; color: #666666; flex: 1">起</text>
                              </view>
                          </view>
                      </scroll-view>
                  </view>

                  <view style="height: 30rpx"></view>

                  <view v-if="recommands && recommands.length > 0">
                      <view class="title_container">
                          <image class="title_container_text_icon" src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/icon/icon_hot.png"></image>
                          <view class="title_container_text">热门推荐</view>
                      </view>
                      <view class="shop_flow">
                          <block v-for="(recommandItem, recommandIndex) in recommands" :key="recommandIndex">
                              <view class="shop_flow_item" @tap="toRecommand" :data-item="recommandItem">
                                  <view style="position: relative">
                                      <block v-if="recommandIndex % 2 == 0">
                                          <van-image lazy-load fit="cover" radius="16rpx" :src="recommandItem.mainPicUrlW" width="336rpx" height="336rpx" />
                                      </block>
                                      <block v-else>
                                          <van-image lazy-load fit="cover" radius="16rpx" :src="recommandItem.mainPicUrlH" width="336rpx" height="418rpx" />
                                      </block>
                                      <view class="shop_tag_container">
                                          <van-tag type="primary" v-for="(recommandLabel, index) in util.splitLabel(recommandItem.especialLabel)" :key="index">
                                              {{ recommandLabel }}
                                          </van-tag>
                                      </view>
                                  </view>
                                  <view class="shop_title">{{ recommandItem.shopName }}</view>
                                  <view class="flex_row_b shop_desc">
                                      <text style="font-size: 22rpx; color: #ff6700; font-weight: bold">￥</text>
                                      <text style="font-size: 36rpx; color: #ff6700; font-weight: bold">{{ recommandItem.startingPriceYuan }}</text>
                                      <text style="font-size: 22rpx; color: #666666; flex: 1">起</text>
                                  </view>
                              </view>

                              <view class="null_wrap"></view>
                          </block>
                      </view>
                  </view>
              </scroll-view>

              <view v-else-if="activeTab == 1">
                  <!-- <scale-banner pageCount="3" autoplay="true" />
    <scale-banner pageCount="5" /> -->
                  <view style="height: 24rpx"></view>

                  <view class="culture_text">{{ aboutUsText }}</view>
                  <view class="title_container" @tap="toCultrueTrends">
                      <view class="title_container_text">公司动态</view>
                      <view class="title_container_more">查看全部</view>
                      <van-icon style="margin: 0 4rpx" class-prefix="iconfont" name="chakanquanbu" size="16rpx" color="#999999"></van-icon>
                  </view>
                  <scroll-view :scroll-x="true" class="cultrue_scroller">
                      <view class="cultrue_scroller_item" @tap="onNewsClick" :data-item="cultrueItem" v-for="(cultrueItem, cultrueIndex) in introduceNews" :key="cultrueIndex">
                          <van-image
                              :src="cultrueItem.resType == 1 ? cultrueItem.videoImg : cultrueItem.resUrl"
                              width="642rpx"
                              height="360rpx"
                              radius="20rpx"
                              :custom-class="cultrueIndex == 0 ? 'topic_image_first' : 'topic_image'"
                          ></van-image>

                          <image v-if="cultrueItem.resType == 1" class="play_icon" src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/icon/play.png"></image>
                      </view>
                  </scroll-view>

                  <view style="height: 10rpx"></view>

                  <view class="title_container" @tap="toCultrueBrand">
                      <view class="title_container_text">品牌实力</view>
                      <view class="title_container_more">查看全部</view>
                      <van-icon style="margin: 0 4rpx" class-prefix="iconfont" name="chakanquanbu" size="16rpx" color="#999999"></van-icon>
                  </view>
                  <van-grid custom-class="cultrue_grid" column-num="2" :border="false" gutter="11rpx">
                      <van-grid-item :use-slot="true" v-for="(image, index) in brandImages" :key="index">
                          <van-image radius="20rpx" style="display: block" width="340rpx" height="190rpx" fit="cover" :src="image" />
                      </van-grid-item>
                  </van-grid>
                  <view class="cultrue_message">
                      <view class="flex_column flex_1" style="justify-content: space-around">
                          <view class="flex_row_c">
                              <image
                                  style="width: 28rpx; height: 28rpx; margin-right: 8rpx"
                                  src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/icon/cultrue_mobile.png"
                              ></image>
                              <text>(0579)82328118 13867972265</text>
                          </view>
                          <view class="flex_row_c">
                              <image
                                  style="width: 28rpx; height: 28rpx; margin-right: 8rpx"
                                  src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/icon/cultrue_time.png"
                              ></image>
                              <text>工作时间：周一至周日 08:00-22:00</text>
                          </view>
                          <view class="flex_row_c">
                              <image
                                  style="width: 28rpx; height: 28rpx; margin-right: 8rpx"
                                  src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/icon/cultrue_location.png"
                              ></image>
                              <text>办公地址：金华市双龙南街1151号丽晶国际商务大厦5楼</text>
                          </view>
                      </view>
                      <image
                          src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/index/kefuqrcode.jpg"
                          :show-menu-by-longpress="true"
                          style="width: 176rpx; height: 176rpx"
                      ></image>
                  </view>
              </view>

              <view v-else style="background-color: #f6f7f9">
                  <image class="person-bg" src="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/bg_20230112.png" mode="aspectFit" />
                  <view class="person-main">
                      <view class="person-cell" style="margin-top: 220rpx">
                          <!-- 内容登录 -->
                          <view v-if="personalInfo" @tap="toPersonalInfo">
                              <view class="flex_row_c">
                                  <view class="flex_1">
                                      <van-image class="avatar" round width="120rpx" height="120rpx" :src="personalInfo.avatar" fit="cover"></van-image>
                                      <view style="padding: 24rpx 0 0 184rpx">
                                          <view style="font-size: 36rpx; line-height: 36rpx; min-height: 36rpx; font-weight: bolder">
                                              {{ personalInfo.nickname }}
                                          </view>
                                          <view style="font-size: 28rpx; line-height: 28rpx; min-height: 28rpx; color: #999999; margin-top: 10rpx">
                                              {{ personalInfo.phone }}
                                          </view>
                                      </view>
                                      <view class="flex_row_b person-count-row">
                                          <view class="person-count-container" @tap="toCollection">我的收藏</view>
                                          <view style="padding: 0rpx 16rpx 0rpx 16rpx; font-size: 32rpx; color: #333333; font-weight: bolder">
                                              {{ personalInfo.collectNums }}
                                          </view>
                                          <view style="margin-top: 13rpx; background-color: #d8d8d8; width: 2rpx; height: 20rpx"></view>
                                          <view class="person-count-container" @tap="toHistory">浏览足迹</view>
                                          <view style="padding: 0rpx 16rpx 0rpx 16rpx; font-size: 32rpx; color: #333333; font-weight: bolder">
                                              {{ personalInfo.footprintNums }}
                                          </view>
                                      </view>
                                  </view>

                                  <view class="person-setting">
                                      <view class="flex_row_c" style="background-color: #f6f7f9; width: 148rpx; border-radius: 32rpx 0rpx 0rpx 32rpx">
                                          <van-icon
                                              style="margin-left: 24rpx"
                                              class-prefix="iconfont"
                                              name="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/setting_20230112.png"
                                              size="32rpx"
                                          ></van-icon>
                                          <view style="padding-left: 12rpx; font-size: 28rpx">设置</view>
                                      </view>
                                  </view>
                              </view>
                          </view>
                          <!-- 未内容登录 -->
                          <view v-else class="flex_column_c" style="justify-content: center; height: 208rpx">
                              <text style="color: #333333; font-size: 36rpx; font-weight: bold">您好！请登录</text>
                              <van-button
                                  round
                                  color="linear-gradient(270deg, #FE7C02 0%, #FFAC12 100%)"
                                  style="--button-default-height: 64rpx; margin-top: 20rpx"
                                  @tap.native="login"
                              >
                                  登录/注册
                              </van-button>
                          </view>
                      </view>
                      <view class="person-cell">
                          <view class="person-row">
                              <view class="person-cell-title flex_1">订单信息</view>
                              <view style="padding-right: 12rpx; align-self: center; color: #999999; font-size: 28rpx" @tap="toOrderList" :data-tab-index="0">全部订单</view>
                              <van-icon style="padding-right: 36rpx; vertical-align: middle" class-prefix="iconfont" name="chakanquanbu" size="20rpx" color="#666666"></van-icon>
                          </view>
                          <view class="person-row">
                              <view class="person-grid-item person-column" @tap="toOrderList" data-tab-index="1">
                                  <van-icon
                                      class-prefix="iconfont"
                                      name="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/topay_20230112.png"
                                      size="55rpx"
                                  ></van-icon>
                                  <view class="person-grid-item-title">待支付</view>
                              </view>
                              <view class="person-grid-item person-column" @tap="toOrderList" data-tab-index="2">
                                  <van-icon
                                      class-prefix="iconfont"
                                      name="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/toexchange_20230112.png"
                                      size="55rpx"
                                  ></van-icon>
                                  <view class="person-grid-item-title">待核销</view>
                              </view>
                              <view class="person-grid-item person-column" @tap="toOrderList" data-tab-index="3">
                                  <van-icon
                                      class-prefix="iconfont"
                                      name="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/close_20230112.png"
                                      size="55rpx"
                                  ></van-icon>
                                  <view class="person-grid-item-title">已关闭</view>
                              </view>
                              <view class="person-grid-item person-column" @tap="toOrderList" data-tab-index="3">
                                  <van-icon
                                      class-prefix="iconfont"
                                      name="https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/done_20230112.png"
                                      size="55rpx"
                                  ></van-icon>
                                  <view class="person-grid-item-title">已完成</view>
                              </view>
                          </view>
                      </view>

                      <view class="person-cell">
                          <view class="person-cell-title">常用功能</view>

                          <view class="person-row">
                              <view :data-item="item" class="person-grid-item person-column" @tap="onModuleClick" v-for="(item, idx) in moduleIcons" :key="idx">
                                  <van-icon class-prefix="iconfont" :name="item.icon" size="55rpx"></van-icon>

                                  <view class="person-grid-item-title">{{ item.title }}</view>
                              </view>
                          </view>
                      </view>

                      <view class="person-cell">
                          <view class="person-cell-title">声明与协议</view>

                          <van-grid custom-class="person-grid" clickable column-num="4" :border="false">
                              <van-grid-item custom-class="person-grid-padding" link-type="navigateTo" :url="item.page" v-for="(item, idx) in protocolIcons" :key="idx">
                                  <van-icon slot="icon" class-prefix="iconfont" :name="item.icon" size="48rpx"></van-icon>

                                  <view slot="text">
                                      {{ item.title }}
                                  </view>
                              </van-grid-item>
                          </van-grid>
                      </view>
                  </view>
              </view>
          </view>

          <customTabBar class="safe_area_bottom" :active-idx="activeTab" @onTabClick="onTabClick"></customTabBar>

          <custom-server :show.sync="showCustomServerDialog"></custom-server>
      </view>

      <van-toast id="van-toast" />
      <van-dialog id="van-dialog" @getphonenumber="getPhoneNumber($event, { tagId: 'van-dialog' })" />
  </view>
</template>
<!-- <script module="util" lang="wxs" src="@/wxs/util.wxs"></script> -->
<!-- <script>
import customServer from '@/components/customService/index';
// import customTabBar from "@/components/customTabBar/index"; // PS: 此组件与全局组件重名，已注释（可能误判，请开发者根据实际情况处理）。
import indexNavigate from '@/components/navigate/index/index';
import scaleBanner from '@/components/scaleBanner/index';
import qrcode from '@/components/qrcode/index';
// pages/index/index.js
const constant = require('../utils/const');
const citySelector = requirePlugin('citySelector');
const moment = require('moment');
import Bus from '@/utils/bus';

let wallet = {
  index: 0,
  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/wallet_20230112.png',
  title: '我的钱包',
  page: '/pages/mine/wallet/index'
};
let customer = {
  index: 1,
  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/service_20230112.png',
  title: '联系客服'
};
let about = {
  index: 2,
  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/aboutus_20230112.png',
  title: '关于我们'
};
let feedback = {
  index: 3,
  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/feedback_20230112.png',
  title: '建议反馈',
  page: '/pages/mine/feedback/index'
};
let bussiness = {
  index: 4,
  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/businesschat_20230112.png',
  title: '商务洽谈',
  page: '/pages/mine/businessChat/index'
};
let store = {
  index: 5,
  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/business_20230112.png',
  title: '我是商家',
  page: ''
};
let coupon = {
  index: 6,
  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/coupon_20240221.png',
  title: '我的券包',
  page: '/pages/mine/coupon/list/index'
};
let logout = {
  index: 7,
  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/logout_20240221.png',
  title: '退出账号',
  page: ''
};
export default {
  components: {
      customServer,
      indexNavigate,
      scaleBanner,
      qrcode
  },
  data() {
      return {
          areaCode: '330700',
          areaName: '金华市',

          indexMenus: [
              {
                  title: '共富商家',
                  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/shengji/gongfushangj.png'
              },
              {
                  title: '基地',
                  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/shengji/jidi.png'
              },
              {
                  title: '旅游',
                  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/shengji/lvyou.png'
              },
              {
                  title: '直播',
                  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/shengji/zhibo.png'
              }
          ],

          activeTab: 0,
          indexScrollHeight: 0,
          indexTopBanners: [],
          indexMiddleBanners: [],
          latestShops: [],
          recommands: [],
          moduleIcons: [],
          showCustomServerDialog: false,

          protocolIcons: [
              {
                  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/disclaimer_20230112.png',
                  title: '免责声明',
                  page: '/pages/webview/index?url=https://api.jhcqgl.cn/mzsm.html'
              },
              {
                  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/privacy_20230112.png',
                  title: '隐私保护',
                  page: '/pages/webview/index?url=https://api.jhcqgl.cn/travel_privacy_policy.html'
              },
              {
                  icon: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/static/res/person/vip_20230112.png',
                  title: '会员协议',
                  page: '/pages/webview/index?url=https://api.jhcqgl.cn/fwxy.html'
              }
          ],

          personalInfo: null,
          aboutUsText: '',
          introduceNews: [],
          introduceBrand: [],
          externalClasses: ['label_class'],

          computed: {
              indexTitleBackground(data) {
                  return data.indexScrollHeight > 270 ? 'white' : 'transparent';
              },
              brandImages(data) {
                  if (data.introduceBrand && data.introduceBrand.length > 0) {
                      return data.introduceBrand[0].imgUrlList;
                  } else {
                      return [];
                  }
              }
          },

          navTop: '',
          navContentHeight: '',
          tabIndex: 0,

          menu: {
              icon: '',
              title: ''
          },

          banner: {
              picUrl: ''
          },

          shopLatesetItem: {
              mainPicUrlW: '',
              shopName: '',
              startingPriceYuan: ''
          },

          shopLatestIndex: 0,
          label: '',
          recommandIndex: 0,

          recommandItem: {
              mainPicUrlW: '',
              mainPicUrlH: '',
              shopName: '',
              startingPriceYuan: ''
          },

          recommandLabel: '',

          cultrueItem: {
              resType: 0,
              videoImg: '',
              resUrl: ''
          },

          cultrueIndex: 0,
          brandImages: [],
          image: ''
      };
  },
  mixins: [require('@/behaviors/navi-behavior'), require('@/behaviors/base-behavior'), require('@/behaviors/lbs-behavior'), require('miniprogram-computed').behavior],
  onLoad(option) {
      this.getLocation({
          getAreaCode: true
      }).then(() => {
          this.setData({
              areaCode: uni.getStorageSync(constant.area_code_key),
              areaName: uni.getStorageSync(constant.area_name_key)
          });
      });
      this.getBanners();
      this.getLatestShops();
      this.getRecommended();
      this.getAboutUs();
      Bus.$on('onLogin', () => {
          this.getPersonalInfo();
      });
      Bus.$on('toIndex', () => {
          this.setData({
              activeTab: 0
          });
      });
  },
  onShareAppMessage() {
      return {
          title: '别样春秋',
          path: `/pages/index/index`
      };
  },
  onShareTimeline() {
      return {
          title: '别样春秋'
      };
  },
  onShow() {
      let temp = []
          .concat(wallet)
          .concat(customer)
          .concat(about)
          .concat(feedback)
          .concat(bussiness)
          .concat(store)
          .concat(coupon)
          .concat(this.isLogin() ? logout : []);
      this.setData({
          moduleIcons: temp
      });
      const selectedCity = citySelector.getCity();
      if (selectedCity != null) {
          this.setData({
              areaName: selectedCity.fullname,
              areaCode: selectedCity.id
          });
          uni.setStorageSync(constant.area_code_key, selectedCity.id);
          uni.setStorageSync(constant.area_name_key, selectedCity.fullname);
          this.getLatestShops();
          this.getRecommended();
      } else {
          let areaCode = uni.getStorageSync(constant.area_code_key);
          if (this.areaCode != areaCode) {
              this.setData({
                  areaCode: areaCode,
                  areaName: uni.getStorageSync(constant.area_name_key)
              });
              this.getLatestShops();
              this.getRecommended();
          }
      }
  },
  onUnload() {
      Bus.$off('onLogin');
      Bus.$off('toIndex');
      citySelector.clearCity();
  },
  methods: {
      login() {
          uni.navigateTo({
              url: '/pages/mine/login/index'
          });
      },

      getBanners() {
          this.setData({
              indexTopBanners: [
                  {
                      id: 1,
                      picUrl: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/shengji/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250303101344.png'
                  },
                  {
                      id: 2,
                      picUrl: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/shengji/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250303101351.png'
                  },
                  {
                      id: 3,
                      picUrl: 'https://cq-prd.oss-cn-hangzhou.aliyuncs.com/shengji/0a30bfb353260883ef52bdea66a8822.png'
                  }
              ]
          });
          this.requestApi({
              url: '/front/banner/getByModule',
              data: {
                  module: 'home_middle'
              }
          }).then((res) =>
              this.setData({
                  indexMiddleBanners: res
              })
          );
      },

      getLatestShops() {
          return this.requestApi({
              url: '/front/shop/latestLimit',
              data: {
                  areaCode: this.areaCode,
                  limit: 10
              }
          }).then((res) => {
              this.setData({
                  latestShops: res
              });
          });
      },

      getRecommended() {
          let location = uni.getStorageSync(constant.user_location_key);
          return this.requestApi({
              url: '/front/shop/recommendDisDirectionShop',
              data: {
                  areaCode: this.areaCode,
                  latitude: location.latitude,
                  longitude: location.longitude
              }
          }).then((res) => {
              this.setData({
                  recommands: res.list
              });
          });
      },

      onIndexScroll(e) {
          this.setData({
              indexScrollHeight: e.detail.scrollTop
          });
      },

      onTabClick(e) {
          let bannerIndex = e.detail;
          switch (bannerIndex) {
              case 2:
                  if (this.isLogin()) {
                      this.getPersonalInfo();
                  }
                  this.setData({
                      activeTab: bannerIndex
                  });
                  break;
              default:
                  this.setData({
                      activeTab: bannerIndex
                  });
                  break;
          }
      },

      onClickBanner(e) {
          this.onLogin(() => {
              let banner = e.currentTarget.dataset.item;
              switch (banner.jumpType) {
                  case 0:
                      if (banner && banner.jumpUrl && banner.jumpUrl.startsWith('/pages/')) {
                          uni.navigateTo({
                              url: banner.jumpUrl
                          });
                      }
                      break;
                  case 1:
                      if (banner && banner.jumpUrl && banner.jumpUrl.startsWith('http')) {
                          uni.navigateTo({
                              url: `/pages/webview/index?url=${banner.jumpUrl}`
                          });
                      }
                      break;
                  case 2:
                  case 3:
                      uni.navigateTo({
                          url: banner.jumpUrl
                      });
                      break;
              }
          });
      },

      onMenuClick(e) {
          let index = e.currentTarget.dataset.index;
          switch (index) {
              case 0:
                  this.toHaowu();
                  break;
              case 1:
                  this.toJidi();
                  break;
              case 2:
                  this.toTravel();
                  break;
              case 3:
                  this.toZhibo();
                  break;
          }
      },

      onLiaoxiuTap(e) {
          uni.navigateTo({
              url: '/pages/business/liaoxiu/list/index?publishModuleId=7'
          });
      },

      toLatestDetail(e) {
          let bizId = e.currentTarget.dataset.item.bizId;
          let shopId = e.currentTarget.dataset.item.shopId;
          let categoryTwo = e.currentTarget.dataset.item.categoryTwo;
          this.jumpToDetail(0, categoryTwo, bizId, shopId, false);
      },

      toRecommand(e) {
          let bizId = e.currentTarget.dataset.item.bizId;
          let shopId = e.currentTarget.dataset.item.shopId;
          let categoryTwo = e.currentTarget.dataset.item.categoryTwo;
          this.jumpToDetail(0, categoryTwo, bizId, shopId, false);
      },

      onNewsClick(e) {
          let news = e.currentTarget.dataset.item;
          console.log(news);
          if (news.resType == 1) {
              uni.navigateTo({
                  url: '/pages/video/index?url=' + news.resUrl
              });
          }
      },

      toCultrueTrends() {
          uni.navigateTo({
              url: '/pages/index/news/index'
          });
      },

      toCultrueBrand() {
          uni.navigateTo({
              url: '/pages/index/brand/index'
          });
      },

      onMessageClick(e) {
          let message = e.currentTarget.dataset.message;
          console.log(message);
      },

      onSelectCity() {
          const key = constant.qq_map_auth_key;
          const referer = '别样春秋';
          const hotCitys = '北京,上海,广州,深圳,杭州,重庆,成都';
          uni.navigateTo({
              url: `plugin://citySelector/index?key=${key}&referer=${referer}&hotCitys=${hotCitys}`
          });
      },

      onSearch() {
          uni.navigateTo({
              url: '/pages/index/search/index'
          });
      },

      toPersonalInfo() {
          uni.navigateTo({
              url: '/pages/mine/personalInfo/index',
              events: {
                  refreshPersonalInfo: (res) => {
                      this.getPersonalInfo();
                  }
              }
          });
      },

      toCollection() {
          uni.navigateTo({
              url: '/pages/mine/collection/index'
          });
      },

      toHistory() {
          uni.navigateTo({
              url: '/pages/mine/history/index'
          });
      },

      toOrderList(e) {
          this.onLogin(() => {
              let tabIndex = e.currentTarget.dataset.tabIndex;
              uni.navigateTo({
                  url: '/pages/mine/order/list/index?tabIndex=' + tabIndex
              });
          });
      },

      getPersonalInfo() {
          this.requestApi({
              url: '/front/user/info',
              showLoading: false
          }).then((res) => {
              var phone_regx = /(\d{3})\d*(\d{4})/;
              res.phone = res.phone.replace(phone_regx, '$1****$2');
              this.setData({
                  personalInfo: res
              });
          });
      },

      toHaowu() {
          uni.navigateTo({
              url: `/pages/business/haowu/index/index`
          });
      },

      toJidi() {
          uni.navigateTo({
              url: `/pages/business/jidi/index/index`
          });
      },

      toTravel() {
          uni.navigateTo({
              url: '/pages/business/travel/index'
          });
      },

      toZhibo() {
          uni.getChannelsLiveInfo({
              finderUserName: constant.sph_id,
              success: (res) => {
                  console.log(res);
                  let liveStatus = res.status;
                  switch (liveStatus) {
                      case 2:
                          uni.openChannelsLive({
                              finderUserName: constant.sph_id,
                              success: (res) => {
                                  console.log(res);
                              }
                          });
                          break;
                      case 3:
                          uni.showLoading({
                              title: '请求中...'
                          });
                          uni.getChannelsLiveNoticeInfo({
                              finderUserName: constant.sph_id,
                              success: (res) => {
                                  let startTime = res.startTime;
                                  Toast(`下次直播将在${moment(startTime * 1000).format('YYYY-MM-DD HH:mm:ss')}开启，敬请期待`);
                              },
                              fail: (err) => {
                                  console.log(err);
                                  Toast('暂无直播预告信息');
                              },
                              complete: () => {
                                  uni.hideLoading();
                              }
                          });
                          break;
                  }
              },
              fail: (err) => {
                  Toast('获取直播信息失败');
                  console.log(err);
              }
          });
      },

      onModuleClick(e) {
          let item = e.currentTarget.dataset.item;
          switch (item.index) {
              case 0:
                  {
                      this.onLogin(() => {
                          uni.navigateTo({
                              url: item.page
                          });
                      });
                  }
                  break;
              case 1:
                  {
                      this.setData({
                          showCustomServerDialog: true
                      });
                  }
                  break;
              case 2:
                  {
                      this.setData({
                          activeTab: 1
                      });
                  }
                  break;
              case 3:
                  {
                      this.onLogin(() => {
                          uni.navigateTo({
                              url: item.page
                          });
                      });
                  }
                  break;
              case 4:
                  {
                      this.onLogin(() => {
                          uni.navigateTo({
                              url: item.page
                          });
                      });
                  }
                  break;
              case 5:
                  {
                      this.onLogin(() => {
                          let storeInfo = uni.getStorageSync(constant.store_info_key);
                          if (storeInfo) {
                              uni.navigateTo({
                                  url: '/pages/business/store/index'
                              });
                          } else {
                              uni.navigateTo({
                                  url: '/pages/business/store/choose/index',
                                  events: {
                                      onChooseStore(store) {
                                          uni.navigateTo({
                                              url: '/pages/business/store/index'
                                          });
                                      }
                                  }
                              });
                          }
                      });
                  }
                  break;
              case 6: {
                  this.onLogin(() => {
                      uni.navigateTo({
                          url: item.page
                      });
                  });
                  break;
              }
              case 7:
                  this.onLogin(() => {
                      Dialog.alert({
                          title: '温馨提示',
                          message: '是否确认退出当前账号',
                          showCancelButton: true
                      })
                          .then(() => {
                              uni.removeStorageSync(constant.user_info_key);
                              uni.removeStorageSync(constant.store_info_key);
                              let temp = [].concat(wallet).concat(customer).concat(about).concat(feedback).concat(bussiness).concat(store).concat(coupon);
                              this.setData({
                                  moduleIcons: temp,
                                  personalInfo: null
                              });
                          })
                          .catch((err) => {});
                  });
                  break;
              default:
                  break;
          }
      },

      getAboutUs() {
          this.requestApi({
              url: '/front/introduce/aboutUs'
          }).then((res) => {
              this.setData({
                  aboutUsText: res
              });
          });
          this.requestApi({
              url: '/front/introduce/introduceNews'
          }).then((res) => {
              this.setData({
                  introduceNews: res.list
              });
          });
          this.requestApi({
              url: '/front/introduce/introduceBrand'
          }).then((res) => {
              this.setData({
                  introduceBrand: res.list
              });
          });
      },

      getPhoneNumber(e, _dataset) {
          /* ---处理dataset begin--- */
          this.handleDataset(e, _dataset);
          /* ---处理dataset end--- */
          console.log('占位：函数 getPhoneNumber 未声明');
      }
  }
};
</script> -->
<script setup>
  import customTabBar from '@/components/customTabBar/index'
  import customService from "@/components/customService/index"
</script>
<style>
@import './index.css';
</style>
